import instance from '../util/request'

/**
 * 创建订单
 * @param {*} cart
 */
export const create_order = (cart)=>{
  return instance.post('/order/api/orders',{
    headers:{
      "Content-Type":"application/json"
    },
    data:cart
  })
}

/**
 * 捕获订单
 * @param {*} cart
 */
export const capture_order = (id)=>{
  return instance.post(`/order/api/orders/${id}/capture`,{
    headers:{
      "Content-Type":"application/json"
    }
  })
}

/**
 * 获取指定用户前5条订单数据
 * @param {*} cart
 */
export const user_order = (id)=>{
  return instance.get(`/order/history?id=${id}`)
}

/**
 * 获取所有用户的订单数据
 * @param {*} cart
 */
export const order_list = (page)=>{
  return instance.get(`/order/list`,{
    params:page
  })
}

/**
 * 删除指定订单
 * @param {*} cart
 */
export const del_order = (map)=>{
  return instance.delete(`/order/`,{
    params:map
  })
}
/**
 * 获取指定用户订单
 * @param {*} cart
 */
export const get_user_orders = (data)=>{
    return instance.post(`/order/`,data)
}